<%-- 
    Document   : CheckOut
    Created on : Jul 21, 2011, 10:10:30 AM
    Author     : HOANG ANH
--%>

<%@page import="java.util.Iterator"%>
<%@page import="BUSObject.CartItem"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags/template/" prefix="template" %>
<jsp:useBean id="BeanCart" scope="session" class="BUS.BUSCart" />
<jsp:useBean id="BeanOrder" scope="page" class="BUS.BUSOrder" />
<jsp:useBean id="BeanUsers" scope="page" class="BUS.BUSUsers" />

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Check Out</title>
    </head>
    <template:header level="1"></template:header>
    <template:StartContent level="1"></template:StartContent>
    <%
        int orderID = -1;
        Iterator<CartItem> ItemList = BeanCart.getList();
        if (!ItemList.hasNext()) {
            response.sendRedirect("Cart Empty.jsp");
            return;
        } else {
            orderID = BeanOrder.NewOrder(BeanUsers.getID(request.getRemoteUser()), ItemList);
            BeanCart.clear();
        }
    %>
    <h1>Check Out Completed</h1>
    <h1>Your order ID : <%= orderID%> </h1>
    <template:EndContent></template:EndContent>
    <template:Footer></template:Footer>
</html>
